/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package forms;

import com.sun.lwuit.Command;
import com.sun.lwuit.Container;
import com.sun.lwuit.Dialog;
import com.sun.lwuit.Label;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.layouts.BoxLayout;

/**
 *
 * @author victorinox
 */
public class ReturnWsExceptionDialog extends Dialog {

    private AbstractForm returnForm;

    public void show(Exception ex, AbstractForm returnForm) {
        
        this.returnForm = returnForm;
        setTitle("oops");
        Container panel = new Container();
        panel.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
        panel.addComponent(new Label("Ocorreu um erro"));
        panel.addComponent(new Label(ex.getMessage()));
        
        addCommand(new Command("Voltar") {

            public void actionPerformed(ActionEvent evt) {

                voltarAction();

            }
        });
        addComponent(panel);
        super.show();
    }

    private void voltarAction() {
        if (returnForm == null) {
            InicialForm.getInstance().show();
        } else {
            returnForm.show();
        }
    }
}
